import React, {Component} from "react";

export default class index extends Component {
	state = {count: 0}

	add = () => {
		const {count} = this.state;
		// 对象式的
		// this.setState({count: count + 1}, () => {
		// 	console.log(this.state.count);
		// });
		this.setState((state, props) => {
			return {count: state.count+1}
		});

	}

	render() {
		return (
			<div>
				<h4>当前求和为 {this.state.count}</h4>
				<button onClick={this.add}>点我＋1</button>
			</div>
		);
	}
}